<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>offset()和position()</title>
    <script src="../jquery/jquery.min.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .father {
            position: absolute;
            top: 100px;
            left: 100px;
            width: 200px;
            height: 200px;
            background-color: antiquewhite;
            /* border: 10px solid #000; */
        }

        .son {
            position: absolute;
            top: 10px;
            left: 10px;
            width: 100px;
            height: 100px;
            background-color: green;
        }
    </style>
</head>

<body>
    <div class="father">
        <div class="son"></div>
    </div>

    <script>
        console.log($('.son').offset());//相对于网页 body :110 110
        console.log($('.son').position());//相对于有定位的父元素 10 10
        console.log($('.father').offset());//100 100
        console.log($('.father').position());//100 100
    </script>
</body>

</html>